package org.example;

public class MyProxy2 implements Service {
    private MyInvocationHandler handler;

    public MyProxy2(MyInvocationHandler myInvocationHandler) {
        this.handler = myInvocationHandler;
    }

    @Override
    public String sayHello() {
        try {
            Object result = handler.invoke(this, org.example.Service.class.getMethod("sayHello"), null);
            return (String) result;
        } catch (Throwable e) {
            throw new RuntimeException(e);
        }
    }

}
